import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
import tensorflow as tf
# import warnings
#
# # 去除警告
# warnings.filterwarnings("ignore")

# 打印TensorFlow的版本信息
# print(tf.__version__)

# 1. 加法案例--python原生
a = 1
b = 2

c = a + b

print("c:", c)

# 2. 加法案例--TensorFlow
a_t = tf.constant(2)
b_t = tf.constant(3)

c_t = tf.add(a_t, b_t)  # 相加的数的类型要一样
# c_t = a_t + b_t  # 不提倡这种方式进行加法运算

print("c_t:", c_t)

# 开启会话， 不用tf.compat.v1.Session()会报警告
with tf.compat.v1.Session() as sess:
    sum_t = sess.run(c_t)
    print("c_t:", sum_t)

# with tf.Session() as sess:
#     sum_t = sess.run(c_t)
#     print("c_t:", sum_t)
